package com.fd.demo;

import java.util.Scanner;

public class AllTest {
    public static void main(String[] args) {
        // 目标： 完成监控计算器
        // 1,先让用户输入自己的个人信息，身高，体重，性别，年龄
        //2,根据个人信息，计算BMI指数（把数据交给一个独立的方法来计算并返回这个结果）
        //3,根据个人信息，计算BMR指数（把数据交给一个独立的方法来计算并返回这个结果）
         Scanner scanner = new Scanner(System.in);
        System.out.println("请输入身高：");
        double height = scanner.nextDouble();
        System.out.println("请输入体重：");
        double weight = scanner.nextDouble();
        System.out.println("请输入性别：");
        String sex = scanner.next();
        System.out.println("请输入年龄：");
        int age = scanner.nextInt();
        double bmi = BMICalculator.calculateBMI(height, weight);
        System.out.println("BMI指数为：" + bmi);
        double bmr = BMICalculator.calculateBMR(height, weight, sex, age);
        System.out.println("BMR指数为：" + bmr);
    }
    public static class BMICalculator {
        public static double calculateBMI(double height, double weight) {
            return weight / (height * height);
        }
        public static double calculateBMR(double height, double weight, String sex, int age) {
           double bmr = 0;
            if ("男".equals(sex)) {
                bmr = 88.362 + (13.397 * weight + 4.799 * height - 5.677 * age);
            } else {
                bmr = 447.593 + (9.247 * weight + 3.098 * height - 4.330 * age);
            }
            return bmr;
        }
    }

}
